package com.kongmou.Springmvc.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.kongmou.Springmvc.Entity.DemoObj;

@RestController // 包含@Controller和@ResponseBody
@RequestMapping("/rest")
public class DemoRestController {

	@RequestMapping(value = "/getjson", produces = { "application/json;charset=UTF-8" })
	public DemoObj getjson(DemoObj obj) {
		return new DemoObj(obj.getId() + 1, obj.getName() + "yy");// 自动转换成json格式
	}

	@RequestMapping(value = "/getxml", produces = { "application/xml;charset=UTF-8" })
	public DemoObj getxml(DemoObj obj) {
		return new DemoObj(obj.getId() + 1, obj.getName() + "yy");// 自动转换成xml格式
	}

}
